# import redis

# r = redis.Redis(host="192.168.1.65", port=6379, db=0)
# r.lpush("name", "yn")
# r.lpush("name", "mlll")
# print(r.lrange("name",0,-1))
# r.lrem("name", 1, "mlll")
# print(r.lrange("name",0,-1))


# 雪花算法
# import snowflake.client

# snowflake.client.setup(host="127.0.0.1",port=8910)

# print(snowflake.client.get_stats())


# id = snowflake.client.get_guid()
# print(id)
# # 4430926437960126465
# b = bin(id)
# print(b)
# # 0b11110101111101110100000100100111001111100000000001000000000001
# print(int('00001',2))
# # print(int('00001',2))

# 压缩字符串
# import sys
# import zlib

# message = "abcdefghijklmn"
# print(sys.getsizeof(message))
# commpressed = zlib.compress(message.encode())
# print(sys.getsizeof(commpressed))

# decompressed = zlib.decompress(commpressed).decode()
# print(decompressed)
# print(sys.getsizeof(decompressed))


# 全文检索
# from elasticsearch import Elasticsearch
 
# es = Elasticsearch(hosts=[{"host":'127.0.0.1', "port": 9200}])

# # 建立索引
# result = es.indices.create(index='article', ignore=400)
# print(result)

#删除索引
# result = es.indices.delete(index='article', ignore=[400])
# print(result)


# 插入数据,这里使用的index创建的，也可以使用creat但需要手动指定一个id
# data = {'title': 'hello world', 'url': 'http://123.com','content':"在北京"}
# result = es.index(index='article',body=data)
# print(result)

# # 修改数据
# data = {"content":"在上海"}
# result = es.index(index="article",body=data,id="RdXRHnYBkMnwDZevsAYF")




# 删除
# result = es.delete(index='article',id='RdXRHnYBkMnwDZevsAYF')
# print(result)
# 查询数据
# result = es.search(index="article")
# print(result)


# mapping = {
#     'query': {
#         'match': {
#             'content': '北京'
#         }
#     }
# }

# result = es.search(index='article',body=mapping)
# print(result)

# [{'_index': 'article', '_type': '_doc', '_id': 'RNXRHnYBkMnwDZevkQYJ', '_score': 0.7133499, '_source': {'title': 'hello world', 'url': 'http://123.com', 'content': '在北京'}}, {'_index': 'article', '_type': '_doc', '_id': 'RtXTHnYBkMnwDZev2QZA', '_score': 0.7133499, '_source': {'title': 'hello world', 'url': 'http://123.com', 'content': '在北京'}}]

# {'acknowledged': True}

# {'acknowledged': True, 'shards_acknowledged': True, 'index': 'article'}


a = (1,"123", [1,2,3],)
print(a)

# coding:utf-8


class Foo(object):
    X = 1
    Y = 2

    @staticmethod
    def averag(*mixes):
        return sum(mixes) / len(mixes)

    @staticmethod
    def static_method():
        return Foo.averag(Foo.X, Foo.Y)

    @classmethod
    def class_method(cls):
        return cls.averag(cls.X, cls.Y)


class Son(Foo):
    X = 3
    Y = 5

    @staticmethod
    def averag(*mixes):
        return sum(mixes) / 3

# p = Son()
# print(p.static_method())
# print(p.class_method())

